using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableSkillCastDao:DaoBase<TableSkillCast>
    {
        public override void AddPrimaryIndex(TableSkillCast model)
        {
            cachePrimary[model.SkillCastId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableSkillCast.txt";
        }

        protected override TableSkillCast ParseRowData(string[] rowData)
        {
            TableSkillCast data = new TableSkillCast();
			data.SkillCastId = rowData [0];
			data.SkillId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.CastTime = 0;
            }
            else
            {
                data.CastTime = double.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.CauseSpeState = 0;
            }
            else
            {
                data.CauseSpeState = int.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.AdvSpeState = 0;
            }
            else
            {
                data.AdvSpeState = int.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.SelectStrategy = 0;
            }
            else
            {
                data.SelectStrategy = int.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.ExportFactor = 0;
            }
            else
            {
                data.ExportFactor = double.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.ExportType = 0;
            }
            else
            {
                data.ExportType = int.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.AddAnger = 0;
            }
            else
            {
                data.AddAnger = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.BehitStiffTime = 0;
            }
            else
            {
                data.BehitStiffTime = double.Parse(rowData[9]);
            }
			data.BehitEffectEnemy = rowData [10];
			data.BehitEffBone = rowData [11];
			data.BehitEffSelf = rowData [12];
			data.BehitEffOffset = rowData [13];
			data.BehitAudio = rowData [14];
			data.GroundEffect = rowData [15];

            if (string.IsNullOrEmpty(rowData[16]))
            {
                data.BuffTriggerClass0 = 0;
            }
            else
            {
                data.BuffTriggerClass0 = int.Parse(rowData[16]);
            }

            if (string.IsNullOrEmpty(rowData[17]))
            {
                data.Buff0TriggerCondition = 0;
            }
            else
            {
                data.Buff0TriggerCondition = int.Parse(rowData[17]);
            }
			data.Buff0ConditionArgs = rowData [18];
			data.BufferId0 = rowData [19];

            if (string.IsNullOrEmpty(rowData[20]))
            {
                data.Buff0SelStr = 0;
            }
            else
            {
                data.Buff0SelStr = int.Parse(rowData[20]);
            }

            if (string.IsNullOrEmpty(rowData[21]))
            {
                data.BufferPercent0 = 0;
            }
            else
            {
                data.BufferPercent0 = double.Parse(rowData[21]);
            }

            if (string.IsNullOrEmpty(rowData[22]))
            {
                data.BuffTriggerClass1 = 0;
            }
            else
            {
                data.BuffTriggerClass1 = int.Parse(rowData[22]);
            }

            if (string.IsNullOrEmpty(rowData[23]))
            {
                data.Buff1TriggerCondition = 0;
            }
            else
            {
                data.Buff1TriggerCondition = int.Parse(rowData[23]);
            }
			data.Buff1ConditionArgs = rowData [24];
			data.BufferId1 = rowData [25];

            if (string.IsNullOrEmpty(rowData[26]))
            {
                data.Buff1SelStr = 0;
            }
            else
            {
                data.Buff1SelStr = int.Parse(rowData[26]);
            }

            if (string.IsNullOrEmpty(rowData[27]))
            {
                data.BufferPercent1 = 0;
            }
            else
            {
                data.BufferPercent1 = double.Parse(rowData[27]);
            }

            if (string.IsNullOrEmpty(rowData[28]))
            {
                data.BuffTriggerClass2 = 0;
            }
            else
            {
                data.BuffTriggerClass2 = int.Parse(rowData[28]);
            }

            if (string.IsNullOrEmpty(rowData[29]))
            {
                data.Buff2TriggerCondition = 0;
            }
            else
            {
                data.Buff2TriggerCondition = int.Parse(rowData[29]);
            }
			data.Buff2ConditionArgs = rowData [30];
			data.BufferId2 = rowData [31];

            if (string.IsNullOrEmpty(rowData[32]))
            {
                data.Buff2SelStr = 0;
            }
            else
            {
                data.Buff2SelStr = int.Parse(rowData[32]);
            }

            if (string.IsNullOrEmpty(rowData[33]))
            {
                data.BufferPercent2 = 0;
            }
            else
            {
                data.BufferPercent2 = double.Parse(rowData[33]);
            }
			data.ProjectId = rowData [34];
			data.ProjPos = rowData [35];

            if (string.IsNullOrEmpty(rowData[36]))
            {
                data.ProjFlyType = 0;
            }
            else
            {
                data.ProjFlyType = int.Parse(rowData[36]);
            }

            if (string.IsNullOrEmpty(rowData[37]))
            {
                data.FlyTime = 0;
            }
            else
            {
                data.FlyTime = double.Parse(rowData[37]);
            }
			data.ProjTargetBone = rowData [38];

            if (string.IsNullOrEmpty(rowData[39]))
            {
                data.ShakeScreen = 0;
            }
            else
            {
                data.ShakeScreen = int.Parse(rowData[39]);
            }

            return data;
        }


        public override void AddOneIndex(TableSkillCast model)
        {
            if (!cacheOneIndex.ContainsKey(model.SkillId.ToString()))
            {
                cacheOneIndex[model.SkillId.ToString()] = new List<TableSkillCast>();
            }
            cacheOneIndex[model.SkillId.ToString()].Add(model);
        }
    

    }

}
